import request from "@/utils/axios";

/**
 * 商户信息更新-显示查询
 * @returns {Promise<{return_msg,return_code,data<Array<{id,user_id,company_name,license_code,contacts,phone,mail,bank_name,account_name,account,currency,exchange_rate,created_at,updated_at}>>,level:Array<{level}>}>}
 */
export const reqSelMerchant = (user_id) => {
  return request.post("/selMerchant", {
    user_id,
  });
};

/**
 * 商户信息更新—更新保证金
 * @returns {Promise<{return_msg,return_code}>}
 */
export const reqModifyMerchant = ({
  user_id,
  company_name,
  license_code,
  contacts,
  phone,
  mail,
  bank_name,
  account_name,
  account,
  currency,
  exchange_rate,
}) => {
  return request.post("/modifyMerchant", {
    user_id,
    company_name,
    license_code,
    contacts,
    phone,
    mail,
    bank_name,
    account_name,
    account,
    currency,
    exchange_rate,
  });
};

// modifyMerchantMargin
export const reqModifyMerchantMargin = ({
  user_id,
  data,
}) => {
  return request.post("/modifyMerchantMargin", {
    user_id,
    data,
  });
};
/**
 * 渠道代理汇总
 * @returns {Promise<{return_msg,return_code,cdata<Array<{cid,country,currency,channel_code,pay_type_code_name,rate,cost,settlement_method,status,level}>>,level:Array<{level}>,bdata}>}
 */
export const reqChannelInterface = (ouser_id) => {
  return request.post("/channelInterface", {
    ouser_id,
  });
};

/**
 * 渠道代理汇总-修改星级
 * @returns {Promise<{return_msg,return_code}>}
 */
export const reqModifyLevel = ({ ouser_id, cid, bid, level }) => {
  return request.post("/modifyLevel", {
    ouser_id,
    cid,
    bid,
    level,
  });
};

/**
 * 商户信息查询
 * @returns {Promise<{return_msg,return_code,count,data<Array<{mail,company_name,license_code,user_id,contacts,phone,contacts_mail,level,exchange_rate}>>}>}
 */
export const reqSelMerchantList = ({
  ouser_id,
  level,
  company_name,
  mail,
  user_id,
  page,
}) => {
  return request.post("/selMerchantList", {
    ouser_id,
    level,
    company_name,
    mail,
    user_id,
    page,
  });
};

/**
 * 商户信息查询-修改星级
 * @returns {Promise<{return_msg,return_code}>}
 */
export const reqModifyUserLevel = ({ ouser_id, user_id, level }) => {
  return request.post("/modifyUserLevel", {
    ouser_id,
    user_id,
    level,
  });
};

/**
 * 渠道申请审批-显示
 * @returns {Promise<{return_msg,return_code,count,data:Array<{mail,company_name,license_code,user_id,contacts,phone,contacts_mail,level,exchange_rate}>}>}
 */
export const reqSelApplyList = ({ ouser_id, page, user_id }) => {
  return request.post("/selApplyList", {
    ouser_id,
    page,
    user_id,
  });
};

/**
 * 渠道申请审批-更新费用
 * @returns {Promise<{return_msg,return_code}>}
 */
export const reqModifyUserCost = ({ ouser_id, ucid, rate, cost }) => {
  return request.post("/modifyUserCost", {
    ouser_id,
    ucid,
    rate,
    cost,
  });
};

/**
 * 商户信息更新—更新保证金??? 接口名重复
 * @returns {Promise<{return_msg,return_code}>}
 */
export const reqModifyMerchantMoney = ({
  user_id,
  company_name,
  license_code,
  contacts,
  phone,
  mail,
  bank_name,
  account_name,
  account,
  exchange_rate,
}) => {
  return request.post("/modifyMerchantMoney", {
    user_id,
    company_name,
    license_code,
    contacts,
    phone,
    mail,
    bank_name,
    account_name,
    account,
    exchange_rate,
  });
};

/**
 * 渠道申请审批-审核
 */
export const reqModifyUCStatus = ({ ouser_id, ucid, status }) => {
  return request.post("/modifyUCStatus", {
    ouser_id,
    ucid,
    status,
  });
};

/**
 * 运营端-登录
 */
export const reqLogin = ({ mail, code, password }) => {
  return request.post("/login", {
    mail,
    code,
    password,
  });
};

/**
 * 运营端-登出
 */
export const reqLoginOut = (token) => {
  return request.post("/loginOut", {
    token,
  });
};

/**
 * 运营端-首页
 */
export const reqIndex = ({ user_id, ouser_id, currency }) => {
  return request.post("/index", {
    user_id,
    ouser_id,
    currency,
  });
};

/**
 * 运营端-商户提现（代付）审批-显示
 */
export const reqSelWithdrawalAuditList = ({ ouser_id, page, type }) => {
  return request.post("/selWithdrawalAuditList", {
    ouser_id,
    page,
    type,
  });
};

/**
 * 运营端-商户提现（代付）审批-审核：（注：左侧提现和代付两个菜单都是这个接口）
 */
export const reqModifyWithdrawalAudit = ({
  ouser_id,
  withdrawal_id,
  auditing_status,
}) => {
  return request.post("/modifyWithdrawalAudit", {
    ouser_id,
    withdrawal_id,
    auditing_status,
  });
};

/**
 * 运营端-详细订单查询
 */
export const reqSelDetailList = ({
  user_id,
  currency,
  type,
  startdata,
  enddata,
  platform_order,
  channel_order,
  merchant_order,
  status,
  page,
  ouser_id,
}) => {
  return request.post("/selDetailList", {
    user_id,
    currency,
    type,
    startdata,
    enddata,
    platform_order,
    channel_order,
    merchant_order,
    status,
    page,
    ouser_id,
  });
};

/**
 * 运营端-首页-取币种下拉菜单列表
 */
export const reqIndexCurrency = (ouser_id) => {
  return request.post("/indexCurrency", {
    ouser_id,
  });
};
